package org.grayrabbit.cms.publish.generate;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.List;

import org.grayrabbit.cms.entity.PublishTask;
import org.grayrabbit.cms.publish.api.Generatable;


public class MultiGenerater extends AbstractGenerater {
//	private  static Logger log = LoggerFactory.getLogger(MultiGenerater.class);
	private List<Generater> generaters;
	public static int PERCENT = 0;
	private boolean needAddFinised = false;
	
	public MultiGenerater(List<Generater> generaters){
		this.generaters = generaters;
	}
	
	@Override
	public void genFile(PublishTask publishTask) {
		try{
			for (Generater generater : generaters) {
				generater.genFile(publishTask);
			}
			logInfo(publishTask,true,null);
		}catch (Exception e) {
			e.printStackTrace();
			logInfo(publishTask,false,e);
		}
		
	}
	
	


	public void setNeedAddFinised(boolean needAddFinised) {
		this.needAddFinised = needAddFinised;
	}

	@Override
	protected boolean needAddFinished() {
		return needAddFinised;
	}

	@Override
	public ByteArrayOutputStream getStream() throws Exception {
		return null;
	}

	@Override
	protected File getTargetFile() {
		return null;
	}

	@Override
	protected void initRootMap() {
		
	}

	@Override
	protected void logInfo(PublishTask publishTask,boolean success,Throwable t) {
		calcTaskInfo(publishTask, success);
	}
	
	public void setGeneratable(Generatable generatable){
		this.generatable = generatable;
	}

}
